﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SLSYJ.Core.DataInterfaces;
using SLSYJ.Core;
using NHibernate;
using ProjectBase.Data.NHibernate;
using NHibernate.Criterion;

namespace SLSYJ.Data
{
    public class TaskDao : GenericDao<Task>, ITaskDao
    {
        public List<Task> LoadTaskBy(string taskName)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(Task))
                .Add(Expression.Eq("Name", taskName));

            return criteria.List<Task>() as List<Task>;
        }

        public List<Task> LoadTaskByCategoryID(int categoryId)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(Task))
                    .Add(Expression.Eq("CategoryID", categoryId));

            return criteria.List<Task>() as List<Task>;
        }

        public List<Task> LoadTaskByEmployeeCategoryID(int employeeId)
        {
            ICriteria criteria = Session.CreateCriteria(typeof(Task))
                    .Add(Expression.Eq("EmployeeCategoryID", employeeId));

            return criteria.List<Task>() as List<Task>;
        }
    }
}
